﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Пятн
{
    public partial class Form2 : Form
    {
        public PictureBox empty;
        public Image image;
        public int clear;
        public Game1 game;

        public Form2(Image picture)
        {
            clear = 9;
            empty = new PictureBox();
            game = new Game1(this);
            image = picture;
            InitializeComponent();
            richTextBox1.Hide();
            button1.Hide();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (clear == 2 || clear == 4)
            {
                game.Move(1, clear);
            }
            if (game.Analiz() == true)
            {
                Win1 win1 = new Win1();
                win1.Show();
                this.Close();
            }
        }

        private void pictureBox2_Click_1(object sender, EventArgs e)
        {
            if (clear == 1 || clear == 3 || clear == 5)
            {
                game.Move(2, clear);
            }
            if (game.Analiz() == true)
            {
                Win1 win = new Win1();
                win.Show();
                this.Close();
            }
        }

        private void pictureBox3_Click_1(object sender, EventArgs e)
        {
            if (clear == 2 || clear == 6)
            {
                game.Move(3, clear);
            }
            if (game.Analiz() == true)
            {
                Win1 win = new Win1();
                win.Show();
                this.Close();
            }
        }

        private void pictureBox4_Click_1(object sender, EventArgs e)
        {
            if (clear == 1 || clear == 5 || clear == 7)
            {
                game.Move(4, clear);
            }
            if (game.Analiz() == true)
            {
                Win1 win = new Win1();
                win.Show();
                this.Close();
            }
        }

        private void pictureBox5_Click_1(object sender, EventArgs e)
        {
            if (clear == 2 || clear == 4 || clear == 6 || clear == 8)
            {
                game.Move(5, clear);
            }

            if (game.Analiz() == true)
            {
                Win1 win = new Win1();
                win.Show();
                this.Close();
            }
        }
        
        private void pictureBox6_Click_1(object sender, EventArgs e)
        {
            if (clear == 3 || clear == 5 || clear == 9)
            {
                game.Move(6, clear);
            }
            
            if (game.Analiz() == true)
            {
                Win1 win = new Win1();
                win.Show();
                this.Close();
            }
        }

        private void pictureBox7_Click_1(object sender, EventArgs e)
        {
            if (clear ==4 || clear == 8)
            {
                game.Move(7, clear);
            }
            
            if (game.Analiz() == true)
            {
                Win1 win = new Win1();
                win.Show();
                this.Close();
            }
        }

        private void pictureBox8_Click_1(object sender, EventArgs e)
        {
            if (clear == 5 || clear == 7 || clear == 9)
            {
                game.Move(8, clear);
            }
            
            if (game.Analiz() == true)
            {
                Win1 win = new Win1();
                win.Show();
                this.Close();
            }
        }

        private void pictureBox9_Click_1(object sender, EventArgs e)
        {
            if (clear == 6 || clear == 8)
            {
                game.Move(9, clear);
            }
            
            if (game.Analiz() == true)
            {
                Win1 win = new Win1();
                win.Show();
                this.Close();
            }
        }

        private void показатьКартинкуToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Picture1 picture = new Picture1();
            picture.Show();
        }

        private void начатьДругуюИгруToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form1 game = new Form1();
            game.Show();
            this.Close();
        }

        private void выйтиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }

        private void показатьКартинкуToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Picture1 picture = new Picture1();
            picture.BackgroundImage = image;
            picture.Show();
        }

        private void начатьНовуюИгруToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form1 game = new Form1();
            game.Show();
            this.Close();
        }

        private void правилаToolStripMenuItem_Click(object sender, EventArgs e)
        {
            button1.Show();
            richTextBox1.Show();
        }

        private void выходToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }

        private void показатьПромежутокМеждуЧастямиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            game.Location1();
        }

        private void убратьПромежутокМеждуЧастямиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            game.Location2();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            richTextBox1.Hide();
            button1.Hide();
        }

    }
}
